Fix xm mem-max command to restore previous setting if xc.domain_setmaxmem fails.
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 26 Feb 2008 15:02:26 +0000 (15:02 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 26 Feb 2008 15:02:26 +0000 (15:02 +0000)
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
tools/python/xen/xend/XendDomainInfo.py

index 341433f0d306ebacf0258eff10a423e5d98d2f7e..9ff2146ea4086ac8c66caa2ca82ed730959bca95 100644 (file)
@@ -906,6 +906,7 @@ class XendDomainInfo:
         log.debug("Setting memory maximum of domain %s (%s) to %d MiB.",
                   self.info['name_label'], str(self.domid), limit)
 
+        maxmem_cur = self.get_memory_static_max()
         MiB = 1024 * 1024
         self._safe_set_memory('memory_static_max', limit * MiB)
 
@@ -914,6 +915,7 @@ class XendDomainInfo:
             try:
                 return xc.domain_setmaxmem(self.domid, maxmem)
             except Exception, ex:
+                self._safe_set_memory('memory_static_max', maxmem_cur)
                 raise XendError(str(ex))
         xen.xend.XendDomain.instance().managed_config_save(self)